<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class group extends MY_Controller {
	function __construct(){
		parent::__construct();
	}

	function admin_index(){
		$result = $this->groupModel->get();
		$this->_assign("groups", $result);
		$this->_fetch('admin_index');
	}

	function admin_add($id=""){
		if(!empty($id)){
			$where["where"]["id"] = $id;
		  $result = $this->groupModel->get($where);
		  $this->_assign('group', $result);
		  $this->_fetch('admin_add');
		}else{
			$_post = $this->input->post();
			if(!empty($_post["submit"]) AND !empty($_post['name'])){
				$this->load->model("group_model","grpModel");
				$this->grpModel->add($_post);
				redirect(base_url('admin/group'));
			}else{
				$this->_fetch('admin_add');
			}
		}
	}

	function admin_delete($id=""){
		$this->db->delete('ci_group',array('grp_id'=>$id));
		redirect(base_url('admin/group'));
	}

}